<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <span></span>
    <script>
        var input = document.querySelector("input");
        var span = document.querySelector("span");
        var reg =  /^[a-zA-Z0-9\_]{5,12}\@[a-zA-Z0-9]{2,5}\.com$/; 
        input.onblur = function(){
            if(reg.test(this.value)){
                span.innerHTML = "验证通过";
            }else{
                span.innerHTML = "验证失败";
            }
        }
    </script>
</body>
</html>